<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
          width: 200px;
          height: 100px;
          background-color: red;
        }
        .active{
          border: 10px solid pink;
        }
      </style>
</head>
<body>
    <div></div>

    <script>
        // 获取div元素
        var div = document.querySelector('div');
        console.dir(div);
        div.onclick = function() {
            console.log(div);
            div.style.backgroundColor = 'blue';
            // this永远指向调用它的对象
            console.log("this",this);
            // style样式绑定
            this.style.background = "green"
            // class样式绑定
            this.className = "active";
            }

            div.ondblclick = function() {
              console.log("双击");
              console.log("this",this);
              this.style.background = "yellow";
              this.className = "";
            }
    </script>
</body>
</html>